﻿/// <reference path="jquery-1.5.1.min.js" />

/*
<div id="projectList">
<table>
    <thead>
        <tr>
            <th class="sort_asc">
                <a href="/Project?Column=Name&amp;Direction=Descending">Name</a>
            </th>
        </tr>
    </thead>
<tbody>
</tbody>
</table>

<div class="pagination">
    <ul>
        <li class="active pagerButton"><a href="/Project?page=1">1</a></li>
        <li class="pagerButton"><a href="/Project?page=2">2</a></li>
    </ul>
</div>
</div>
*/
function EnableAjaxForGrid(containerId) {
    // Select all links, grab urls and subscribe on click event.
    // Click event will cause AJAX request to the specified url.

    var load = function () {
        var url = $(this).attr('href');
        
        $('#' + containerId).load(url);

        return false;
    };

    var prefix = '#' + containerId + ' :first-child ';

    $(prefix + '.pagerButton > a').click(load);
    $(prefix + '.sort_desc > a').click(load);
    $(prefix + '.sort_asc > a').click(load);
}